package net.onceface.application.dto;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import net.onceface.application.assembler.DisCountAssembler;
import net.onceface.application.assembler.ProductAssembler;
import net.onceface.core.domain.Feature;

public class FeatureDTO implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 7922557029139229720L;
	
	private Long id;
	
	private int version;
	
	private Date createDate;
	
	private Date abolishDate;
	
	private String name;
	
	private boolean disabled;
	
	private DisCountDTO firstDiscount;
	
	private String picture;
	
	private DisCountDTO secondDiscount;
	
	private Integer sortOrder;

	private Date startTime;
	
	private List<ProductDTO> products;
	
	private double money;
	
	private int quantity;
	
	public FeatureDTO(){}
	
	public FeatureDTO(Feature feature){
		this.clone(feature);
		this.setProducts(ProductAssembler.toDTOs(feature.getProducts()));
	}
	
	public FeatureDTO(Long id, int version, String name, String picture){
		this.id = id;
		this.name = name;
		this.picture = picture;
		this.version = version;
	}
	
	private void clone(Feature feature) {
		this.id = feature.getId();
		this.name = feature.getName();
		this.picture = feature.getPicture();
		this.startTime = feature.getStartTime();
		this.abolishDate = feature.getAbolishDate();
		if(feature.getFirstDiscount() != null){
			DisCountAssembler.toDTO(feature.getFirstDiscount());
		}
		if(feature.getSecondDiscount() != null){
			DisCountAssembler.toDTO(feature.getSecondDiscount());
		}
	}
	
	public int getQuantity() {
		return quantity;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public double getMoney() {
		return money;
	}

	public void setMoney(double money) {
		this.money = money;
	}

	public int getVersion() {
		return version;
	}

	public void setVersion(int version) {
		this.version = version;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Date getAbolishDate() {
		return abolishDate;
	}

	public void setAbolishDate(Date abolishDate) {
		this.abolishDate = abolishDate;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean isDisabled() {
		return disabled;
	}

	public void setDisabled(boolean disabled) {
		this.disabled = disabled;
	}

	public DisCountDTO getFirstDiscount() {
		return firstDiscount;
	}

	public void setFirstDiscount(DisCountDTO firstDiscount) {
		this.firstDiscount = firstDiscount;
	}

	public String getPicture() {
		return picture;
	}

	public void setPicture(String picture) {
		this.picture = picture;
	}

	public DisCountDTO getSecondDiscount() {
		return secondDiscount;
	}

	public void setSecondDiscount(DisCountDTO secondDiscount) {
		this.secondDiscount = secondDiscount;
	}

	public Integer getSortOrder() {
		return sortOrder;
	}

	public void setSortOrder(Integer sortOrder) {
		this.sortOrder = sortOrder;
	}

	public List<ProductDTO> getProducts() {
		return products;
	}

	public void setProducts(List<ProductDTO> products) {
		this.products = products;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	
}
